<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace Admin\Controller;

use Think\Controller;

/**
 * Description of LoginController
 *
 * @author zhaokai
 */
class LoginController extends Controller {

    //put your code here

    public function index() {
        $data = $_GET["name"];
        echo $data;
        $this->display();
    }

    public function login() {
        $username = $_POST["username"];
        $password = $_POST["password"];
        $data = D("Admin");
        $param["username"] = $username;
        $data->where($param)->find();
        $data = $data->data();
        if (!$data) {
            $this->display("login/index");
        } 

        if ($password === $data["password"]) {
            session("admin", $username);
            $this->redirect("./index");
        }else{
            echo strcmp($data["password"], $password);
            echo $password;
        }
    }
    
    public function loginout(){
        session("admin",null);
        $this->redirect("login/index");
    }

}
